package com.lbt.mybatis.plus.extend.demo.entity.dto;

import com.lbt.mybatis.plus.extend.annotation.MPESql;
import com.lbt.mybatis.plus.extend.annotation.Where;
import com.lbt.mybatis.plus.extend.bean.QueryField;
import com.lbt.mybatis.plus.extend.demo.mybatis.LocalDateTimeBetweenSingleFieldValueFormatter;
import com.lbt.mybatis.plus.extend.expression.SqlExpression;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * @author zhangjinyu
 * @since 2023-05-16
 */
@Data
public class OrgDto implements QueryField {
    private String queryField;
    @MPESql(
            where = {
                    @Where(expression = SqlExpression.BETWEEN, sqlColumn = "id", sqlTable = "o", unionIndex = 0),
                    @Where(expression = SqlExpression.BETWEEN, sqlColumn = "id", unionIndex = 1),
            }
    )
    private Long id;
    @MPESql(
            where = {
                    @Where(unionIndex = 0, expression = SqlExpression.ILIKE_LEFT, sqlColumn = "credit_code"),
                    @Where(unionIndex = 1, expression = SqlExpression.ILIKE_LEFT, sqlColumn = "credit_code")
            }
    )
    private String creditCode;
    private String name;
    @MPESql(
            where = {
                    @Where(expression = SqlExpression.BETWEEN, sqlColumn = "create_at", fieldValueFormatter = LocalDateTimeBetweenSingleFieldValueFormatter.class, resultWrap = true)
            }
    )
    private LocalDateTime createAt;
}
